<% if should_show_latest_spam_suppression?(@stories) %>
  <div class="crayons-story">
    <p class="crayons-story__body">
      <%= t "views.articles.sign_in_for_full_latest_html",
            link: subforem_aware_sign_up_url(sign_up_path(state: "new-user", signup_subforem: RequestStore.store[:subforem_id])) %>
    </p>
  </div>
<% end %>

<% if !user_signed_in? %>
  <% @sidebar_billboard_first = Billboard.for_display(area: "feed_first", user_signed_in: user_signed_in?) %>
  <% if @sidebar_billboard_first %>
    <%= render partial: "shared/billboard", locals: { billboard: @sidebar_billboard_first, data_context_type: BillboardEvent::CONTEXT_TYPE_HOME } %>
  <% end %>
<% end %>

<%# This second-billboard should be shown between 2nd and 3rd article. %>
<% second_billboard_position = 2 %>

<% if @pinned_article %>
  <% second_billboard_position -= 1 %>
  <%= render partial: "articles/single_story", locals: { story: @pinned_article, pinned: true, featured: @pinned_article.id == @featured_story.id } %>
<% end %>

<% if @featured_story.id && @pinned_article&.id != @featured_story.id %>
  <% second_billboard_position -= 1 %>
  <%= render partial: "articles/single_story", locals: { story: @featured_story, featured: true, pinned: false } %>
<% end %>

<div id="article-index-podcast-div"></div>

<%# This third-billboard should be shown between 7th and 8th article. %>
<% third_billboard_position = second_billboard_position + 5 %>

<div class="substories" id="substories">
  <% if @stories.any? %>
    <% @stories.each_with_index do |story, i| %>
      <% if !user_signed_in? && i == second_billboard_position %>
        <% @sidebar_billboard_second = Billboard.for_display(area: "feed_second", user_signed_in: user_signed_in?) %>
        <% if @sidebar_billboard_second %>
          <%= render partial: "shared/billboard", locals: { billboard: @sidebar_billboard_second, data_context_type: BillboardEvent::CONTEXT_TYPE_HOME } %>
        <% end %>
      <% end %>

      <% if !user_signed_in? && i == third_billboard_position %>
        <% @sidebar_billboard_third = Billboard.for_display(area: "feed_third", user_signed_in: user_signed_in?) %>
        <% if @sidebar_billboard_third %>
          <%= render partial: "shared/billboard", locals: { billboard: @sidebar_billboard_third, data_context_type: BillboardEvent::CONTEXT_TYPE_HOME } %>
        <% end %>
      <% end %>
      <% if story.id != @featured_story.id && story.id != @pinned_article&.id %>
        <%= render partial: "articles/single_story", locals: { story: story, featured: false, pinned: false } %>
      <% else %>
        <% third_billboard_position += 1 %>
      <% end %>
    <% end %>
    <% if @stories.size > 1 %>
      <div class="placeholder-div"></div>
    <% end %>
    <div class="single-article-small-pic" id="article-index-hidden-div" style="display:none"></div>
  <% end %>
</div>

<%= javascript_include_tag "homePageFeedShortcuts", "feedPreviewCards", defer: true %>
